﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>机构注册</title>
    <link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/resource/apple.ico" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link href="/lobsteruiframe/layuiadmin/layui/css/layui.css" rel="stylesheet" />
    <link href="/lobsteruiframe/layuiadmin/style/admin.css" rel="stylesheet" />
    <link rel="stylesheet" href="/lobsteruiframe/layuiadmin/style/login.css" media="all">
    <script src="/lobsteruiframe/layuiadmin/layui/layui.js"></script>
    <script src="/jslib/jquery-3.4.1.min.js"></script>
    <script src="/jslib/lobster.js"></script>

    <style>
        .layadmin-user-login {
            padding: 0px;
        }

        .layadmin-user-login-main {
            width: 490px;
        }

        .msgs1 {
            background: #E6E6E6;
            color: #818080;
            border: 1px solid #CCCCCC;
        }
    </style>
</head>
<body>
    <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login">
        <div class="layadmin-user-login-main">
            <div class="layadmin-user-login-box layadmin-user-login-header">
                <h2>机构注册</h2>
            </div>
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <div class="layui-input">
                        <input type="radio" name="WorkType" value="0" title="生产机构" checked>
                        <input type="radio" name="WorkType" value="1" title="开发机构">
                        <input type="radio" name="WorkType" value="2" title="测试机构">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
                    <input type="text" name="WorkName" id="LAY-worker-reg-workname" placeholder="机构名称" lay-verify="required" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
                    <input type="text" name="CreditCode" id="LAY-worker-reg-creditcode" placeholder="统一社会信用代码" lay-verify="required" class="layui-input">
                </div>

                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-worker-reg-submit">提 交</button>
                </div>
            </div>
        </div>

    </div>
</body>
</html>

<script type="text/javascript">
    lobsterlayui.main(['index', 'layer', 'form', 'element'], {
        data: {
            $layui: null,
        },
        pageload: function () {

            this.initevent();
        },
        //初始化事件
        initevent: function () {
            var self = this;
            var layer = this.data.$layui.layer;
            var form = this.data.$layui.form;
            var element = this.data.$layui.element;

            form.render();

            //提交
            form.on('submit(LAY-worker-reg-submit)', function (obj) {
                var field = obj.field;
                field.UserId = self.getUrlParam("UserId");
                self.CreateWorker(field);
                return false;
            });
        },
        getUrlParam:function(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if(r != null) return unescape(r[2]); return null; //返回参数值
        },
        //注册机构
        CreateWorker: function (field) {
            var layer = this.data.$layui.layer;

            lobsterlayui.POST("/admin/v1/Register/RegWorker", field).then(data => {
                layer.msg('机构注册成功，请等待管理员审核。审核周期3-5个工作日。', {
                    offset: '15px'
                    , icon: 1
                    , time: 2000
                }, function () {
                    location.href = '/admin/login/Index.html';//跳转到登入页
                });
            }).catch(res => {
                layer.msg('注册失败：' + res.msg);
            });
        }

    }, false);


</script>